<?PHP

session_start();

if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) {

header ("Location: index.php");

}

?>
<?php 
require 'config.php';

	$db_handle = mysql_connect($server, $user_name, $pass_word);
	$db_found = mysql_select_db($database, $db_handle);
$comid= $_SESSION['comid'];
	if ($db_found) {
		$balquery = "SELECT * FROM  `Company` WHERE id = $comid";
	$balsult = mysql_query($balquery) or die(mysql_error());
	$balrow = mysql_fetch_array($balsult);
	$curbal = $balrow['curbal'];
	$comname = $balrow['name'];
	
	?>
<!DOCTYPE html>
<html><head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
  <meta name="apple-mobile-web-app-capable" content="yes">
   <meta name="apple-mobile-web-app-status-bar-style" content="black">

   
 <title>iPetty Log</title>
  
  
  
  <link rel="stylesheet" href="/jquery/style.css">
  
  <!-- Extra Codiqa features -->
  <link rel="stylesheet" href="codiqa.ext.css">
  
  <!-- jQuery and jQuery Mobile -->
  <script src="https://d10ajoocuyu32n.cloudfront.net/jquery-1.9.1.min.js"></script>
  <script src="https://d10ajoocuyu32n.cloudfront.net/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>

  <!-- Extra Codiqa features -->
  <script src="https://d10ajoocuyu32n.cloudfront.net/codiqa.ext.js"></script>
   <link href="styling.css" rel="stylesheet" type="text/css">
</head>
<body>
<!-- Home -->
<div data-role="page" id="page1">

    <div data-theme="a" data-role="header">
        <h3>
            <?php echo $comname; ?> - R<?php echo $curbal; ?>
        </h3>
        <?php //NAVBAR
		require 'navbar.php';
		 ?>
    </div>
    <div data-role="content">
    <ul data-role="listview" data-filter="true">
<?php

	$viewquery = "SELECT * 
FROM  `pettyapp_log` 
WHERE comid = $comid
ORDER BY  `tdate` DESC 
LIMIT 0 , 200";
	
	$viewsult = mysql_query($viewquery) or die(mysql_error());
	
	while($viewrow = mysql_fetch_array($viewsult)){
		$dated = date("Y/m/d",$viewrow['tdate']);
		$pinoutme = $viewrow['pinout'];
		
		switch($pinoutme)
		{			
	case "withdraw" : echo "<li style=\"background-color:#FFCC33\">".$dated. " * ". $viewrow['dfor']. " * ".$viewrow['amount']. " * ".$viewrow['comments']."</li>" ;
	break;
	
	case "loan" : echo "<li style=\"background-color:#FF99FF\">".$dated. " * ". $viewrow['dfor']. " * ".$viewrow['amount']. " * ".$viewrow['comments']."</li>" ;
	break;
	
	case "reloan" : echo "<li style=\"background-color:#33CCFF\">".$dated. " * ". $viewrow['dfor']. " * ".$viewrow['amount']. " * ".$viewrow['comments']."</li>" ;
	break;
	
	case "deposit" : echo "<li style=\"background-color:#00FFCC\">".$dated. " * ". $viewrow['dfor']. " * ".$viewrow['amount']. " * ".$viewrow['comments']."</li>" ;
	break;
	
	case "recon" : echo "<li style=\"background-color:#F5F5DC\">".$dated. " * ". $viewrow['dfor']. " * ".$viewrow['amount']. " * ".$viewrow['comments']."</li>" ;

	}
		}
	
	}
	?>
</ul>
    </div>
</div>
</body>
</html>
